<script src="__LAYUI__/layui.js"></script>
<link href="__LAYUI__/css/layui.css" rel="stylesheet"/>
<form class="layui-form layui-form-pane" action="" style="margin: 50px">
    <div class="layui-form-item">
        <label class="layui-form-label">教材名称</label>
        <div class="layui-input-block">
            <input type="text" name="book_name" required  lay-verify="required" placeholder="请输入教材名称" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">教材出版社</label>
        <div class="layui-input-block">
            <input type="text" name="book_company" required  lay-verify="required" placeholder="请输入出版社名称" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item" pane>
        <label class="layui-form-label">字数</label>
        <div class="layui-input-block">
            <input type="text" name="book_word_count" placeholder="请输入著作字数" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item" pane>
        <label class="layui-form-label" style="width:116px;">计划出版时间</label>
        <div class="layui-input-inline">
            <input class="layui-input" id="date" placeholder="yyyy-MM-dd" type="text" name="book_out_datetime">
        </div>
    </div>
    <div class="layui-form-item" pane>
        <label class="layui-form-label" style="width:116px;">书号状态</label>
        <div class="layui-input-inline">
            <select name="status" lay-verify="">
                <option value="待申请">待申请</option>
                <option value="申报中">申报中</option>
                <option value="已下">已下</option>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<script>
    layui.use(['form','jquery','laydate'],function () {
        var form = layui.form,
            $ = layui.$,
            laydat = layui.laydate;

        laydat.render({
            elem: '#date'
        });

        form.on('submit(demo1)', function(data){
            $.post('/index/Material/addBook',data.field,function (res) {
                layer.msg(res.msg, {
                    icon: 1,
                    time: 3000 //2秒关闭（如果不配置，默认是3秒）
                });
                if(res.code){
                    parent.location.reload();
                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                    parent.layer.close(index); //再执行关闭
                }
            })

            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
    })
</script>